/**
 * 知识点：
 * 1.stack配合Positioned布局元素实现绝对定位
*/
import 'package:flutter/material.dart';

class StackRoute extends StatefulWidget {
  const StackRoute({Key? key}) : super(key: key);

  @override
  _StackRouteState createState() => _StackRouteState();
}

class _StackRouteState extends State<StackRoute> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('stack布局'),
      ),
      body: ConstrainedBox(
        constraints: const BoxConstraints.expand(),
        child: Stack(
          alignment: Alignment.center, //垂直居中
          clipBehavior: Clip.hardEdge,
          children: [
            Container(
                height: 100,
                width: 100,
                alignment: Alignment.topLeft,
                child: const Text(
                  'hello world',
                  style: TextStyle(color: Colors.red),
                ),
                color: Colors.blue),//container背景色
            const Positioned(left: 0, child: Text('im jack')),
            const Positioned(top: 50,left:10, child: Text('your friend')),
          ],
        ),
      ),
    );
  }
}
